package com.tiger.utils;


import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;


public class ResponseUtil {
    public static Map<String, Object> successRes() {
        Map<String, Object> result = new HashMap<>();
        result.put("success", true);
        result.put("code", 0);
        result.put("msg", "");
        result.put("data", null);
        return result;
    }


    public static Map<String, Object> successRes(Object data) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", true);
        result.put("code", 0);
        result.put("msg", "");

        result.put("data", data);
        return result;
    }

    public static Map<String, Object> successRes(Object data, Map<String, Object> params, String msg) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", true);
        result.put("code", 0);

        result.put("data", data);
        result.put("msg", msg == null ? "" : msg);


        if (params != null) {
            result.putAll(params);
        }

        return result;
    }

    public static Map<String, Object> failRes(String msg, Map<String, Object> params) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", false);
        result.put("data", null);
        result.put("code", 0);

        result.put("msg", msg == null ? "" : msg);


        if (params != null) {
            result.putAll(params);
        }

        return result;
    }

    public static Map<String, Object> failRes(String msg) {
        Map<String, Object> result = new HashMap<>();
        result.put("success", false);
        result.put("data", null);
        result.put("code", 0);

        result.put("msg", msg == null ? "" : msg);

        return result;
    }

    public static Map<String, Object> failRes() {
        Map<String, Object> result = new HashMap<>();
        result.put("success", false);
        result.put("data", null);
        result.put("code", 0);

        result.put("msg", "");

        return result;
    }
}
